package com.wyd.flowable.config;

import org.flowable.ui.common.model.UserRepresentation;
import org.flowable.ui.common.rest.idm.CurrentUserProvider;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 王叶东
 * @since 2025/6/13 10:11
 */
@Component
public class FlowableUiCurrentUserProvider implements CurrentUserProvider {
    @Override
    public UserRepresentation getCurrentUser(Authentication authentication) {
        UserRepresentation userRepresentation = new UserRepresentation();
        userRepresentation.setId("admin");
        userRepresentation.setFirstName("admin");
        List<String> privileges = new ArrayList<>();
//        privileges.add("flowable-idm");
        privileges.add("flowable-modeler");
//        privileges.add("flowable-task");
        userRepresentation.setPrivileges(privileges);



        return userRepresentation;
    }

    @Override
    public boolean supports(Authentication authentication) {
        return true;
    }
}
